/*
 * SatelliteInterface.h
 *
 *  Created on: 25.05.2011
 *      Author: ansuz
 */

#ifndef SATELLITEINTERFACE_H_
#define SATELLITEINTERFACE_H_

#include "worker-monitor-topics.h"
#include <vector>
#include "resumer.h"
#include <utility>

class SatelliteInterface: public Putter { //,public Thread {
private:
	std::vector<std::pair<int,bool> > nodelist;
	Fifo<WMMessage,20> SatelliteBuffer;
	Subscriber SatelitteSubscriber;
	int WorkerID;
	int PingCount;
	int maxPing;
	operationMode oMode;
	void Ping();
	void WorkerPing();

public:
	SatelliteInterface();

	int getNumNodes();
	int getNumDisabledNodes();
	int getNumResponsiveNodes();
	int* getUnresponsiveNodes();
	int* getResponsiveNodes();
	int* getNodeIDList();
	int getWorkerID();
	void setWorker(int ID);
	void setMonitor(int ID);
	operationMode getMode();
	void setMode(operationMode mode);
	void handleMessages();
	void updateSatellite();

	bool putGeneric(const unsigned int len, const void* msg);
	void init();

	//void run();
};

//static SatelliteInterface test;
static LinkinterfaceUDP linkToNodes;
static Gateway topicGateway(&linkToNodes);
static Resumer gatewayResumer;

#endif /* SATELLITEINTERFACE_H_ */
